Ext.define("Skood.view.user.UserWindow",{
	extend:"Ext.window.Window",
	alias :"widget.userWindow",
	title :"用户信息",
	layout:'fit',
	//autoShow:true,
	width:300,
	modal:true,
	initComponent:function(){
		var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
		Ext.QuickTips.init();
		this.items = [
		    { 	xtype:'form',
		    	url:'/security/doCreateUserAction.do',
		    	bodyPadding: 5,
		    	layout:{
		    		type:'table',
		    		columns:1
		    	},
		    	//frame:true,
		    	fieldDefaults: {
		            labelWidth: 80,
		            
		            msgTarget: 'side'
		        },
		    	items:[{
		    		xtype:'textfield',
		    		name :'entityBean.name',
		    		afterLabelTextTpl: required,
		    		allowBlank:false,
		    		fieldLabel:'用户名',
		    		tooltip: '请输入用户名'
		    	},{
		    		xtype:'textfield',
		    		name:'entityBean.nickName',
		    		afterLabelTextTpl: required,
		    		allowBlank:false,
		    		fieldLabel:'真实姓名',
		    		tooltip:'请输入真实姓名'
		    	},{
		    		xtype:'textfield',
		    		name:'entityBean.email',
		    		fieldLabel:'邮箱',
		    		allowBlank:false,
		    		vtype: 'email'
		    	},{
		    		xtype:'textfield',
		    		name:'entityBean.mobile',
		    		fieldLabel:'手机',
		    		disabled:true
		    	}/*,{
		            xtype: 'checkboxgroup',
		            fieldLabel: '状态',
		            name:'entityBean.status',
		            items: [
		                {boxLabel: '启用', name: 'status',inputValue: 1,checked: true},
		                {boxLabel: '禁用', name: 'status',inputValue: 0}
		            ]
			    }*/,{
		            fieldLabel: '有效期',
		            name: 'entityBean.expireDate',
		            xtype: 'datefield',
		            format:'Y-m-d',
		            tooltip: 'Enter your date of birth'
		        }
		        ]
		    }
		],
		this.buttons=[{
			text:"保存",
			action:'save',
			scope:this,
			handler:this.save
		},{
			text:'取消',
			scope:this,
			handler:this.close
		}],
		this.callParent(arguments);
	},
	save:function(){
		var me = this;
		console.log('Click save button.');
		var form = me.down('form').getForm();
		/*var record = form.getRecord();
		var values = form.getValues();
		record.set(values);*/
		//me.getUsersStore().sync();
		//form.reset();
		if (form.isValid()) {
			console.log('form submit');
		 form.submit({
                    success: function(form, action) {
                    	form.reset();
                    	me.close();
                       Ext.Msg.alert('Success', action.result.msg);
                    },
                    failure: function(form, action) {
                        Ext.Msg.alert('Failed', action.result.msg);
                    }
                });
		};
		//me.close();
	}
	
})